package com.study02.huiwenshuo;

/**
 * Created by wwl on 2022/3/8 20:53
 */
public class HuiWenNumber {
    public static void main(String[] args) {
        boolean huiWen = isHuiWen(1232);
        System.out.println(huiWen);
    }


    public static boolean isHuiWen(int x) {
        //首先删选 x=0、x%10==0,x<0 都为返回false
        if (x < 0 || (x % 10 == 0 && x != 0)) return false;

        int reverseNumber = 0;

        while (x > reverseNumber) {
            reverseNumber = reverseNumber*10 + x%10;
            x/=10;
        }


        return x == reverseNumber || x == reverseNumber/10;
    }

}
